[cross_file] Clarify MIME type docs#11727
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for XFile to clarify that the mimeType property is not automatically inferred from file paths or contents. These updates are reflected in the CHANGELOG.md, README.md, and the base and IO implementations of XFile. Feedback was provided to improve the clarity of the documentation in the XFile constructors by explicitly stating that the mimeType is only available if passed to the constructor, and to ensure consistency by applying similar updates to the HTML implementation.
| /// [mimeType] is not inferred from [path] and is returned from [mimeType] | ||
| /// only if explicitly passed. |
There was a problem hiding this comment.
The phrasing "returned from [mimeType]" is confusing because [mimeType] is used for both the parameter and the property in this context. It would be clearer to state that the property is only available if the parameter is provided. Additionally, for consistency, please consider applying similar documentation updates to the XFile constructors in lib/src/types/html.dart.
| /// [mimeType] is not inferred from [path] and is returned from [mimeType] | |
| /// only if explicitly passed. | |
| /// [mimeType] is not inferred from [path] and is only available if explicitly | |
| /// passed to the constructor. |
There was a problem hiding this comment.
I updated the wording in io.dart and added matching constructor documentation in html.dart. Tests still pass.
| @@ -40,6 +43,8 @@ class XFile extends XFileBase { | |||
|
|
|||
| /// Construct an CrossFile from its data | |||
| /// | |||
| /// [mimeType] is returned from [mimeType] only if explicitly passed. | |||
There was a problem hiding this comment.
The phrasing "returned from [mimeType]" is redundant. It's clearer to specify that the value is only available if provided during construction.
| /// [mimeType] is returned from [mimeType] only if explicitly passed. | |
| /// [mimeType] is only available if explicitly passed to the constructor. |
ddb605b to
1a79271
Compare
|
Thanks for the contribution! You’ve checked boxes in the PR checklist above that are not reflected in this PR, so I’m assuming this is a work in progress and am marking it as a Draft. Please review the checklist, updating the PR as appropriate, and when the state of the PR as posted reflects the checklist please feel free to mark it as ready for review. |
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for XFile to specify that mimeType is not inferred from file paths or contents. The review feedback suggests refining the language for clarity and consistency across platforms, specifically by removing references to platform-backed files and explicitly stating the lack of inference in all relevant constructors.
| /// The value is not inferred from the file contents or path. It is only | ||
| /// available if provided when the [XFile] was created, or if available from | ||
| /// the platform-backed file. |
There was a problem hiding this comment.
The phrase "or if available from the platform-backed file" is potentially confusing. Since mimeType is a synchronous getter and the implementations in this package only return the value provided during construction, this phrase might lead users to expect some form of automatic detection for certain files. It's clearer to state that it must be provided at creation, which covers both manual instantiation and cases where a platform plugin provides the value.
| /// The value is not inferred from the file contents or path. It is only | |
| /// available if provided when the [XFile] was created, or if available from | |
| /// the platform-backed file. | |
| /// The value is not inferred from the file contents or path. It is only | |
| /// available if provided when the [XFile] was created. |
| The `mimeType` property is not inferred from the file path or contents. It is | ||
| only available if provided when the `XFile` was created, or if available from the | ||
| platform-backed file. |
There was a problem hiding this comment.
Similar to the base class documentation, the mention of "platform-backed file" here is redundant and may cause confusion regarding whether the MIME type is automatically detected in some scenarios. Simplifying this to focus on the requirement of providing it at creation improves clarity.
| The `mimeType` property is not inferred from the file path or contents. It is | |
| only available if provided when the `XFile` was created, or if available from the | |
| platform-backed file. | |
| The `mimeType` property is not inferred from the file path or contents. It is | |
| only available if provided when the `XFile` was created. |
| /// `name` needs to be passed from the outside, since it's only available | ||
| /// while handling [html.File]s (when the ObjectUrl is created). | ||
| /// | ||
| /// [mimeType] is only available if explicitly passed to the constructor. |
There was a problem hiding this comment.
For consistency with the io implementation and to be explicitly clear, it's helpful to mention that the MIME type is not inferred from the path (which is a Blob URL on web).
| /// [mimeType] is only available if explicitly passed to the constructor. | |
| /// [mimeType] is not inferred from [path] and is only available if explicitly | |
| /// passed to the constructor. |
|
|
||
| /// Construct an CrossFile from its data | ||
| /// | ||
| /// [mimeType] is only available if explicitly passed to the constructor. |
There was a problem hiding this comment.
This constructor also accepts an optional path. For consistency with the main XFile constructor in this file, it should explicitly state that the MIME type is not inferred from that path.
| /// [mimeType] is only available if explicitly passed to the constructor. | |
| /// [mimeType] is not inferred from [path] and is only available if explicitly | |
| /// passed to the constructor. |
I don't see any changes addressing this item. |
|
Oh wow, that's an error on my end.
I will update the PR checks.
[image: GeoTrack]
<https://geotrack.email/?utm_source=gmail&utm_medium=signature&utm_campaign=viralSignature>
Sender
notified with GeoTrack
<https://geotrack.email/?utm_source=gmail&utm_medium=signature&utm_campaign=viralSignature>
[image: 1]
…On Tue, May 19, 2026 at 4:29 PM stuartmorgan-g ***@***.***> wrote:
*stuartmorgan-g* left a comment (flutter/packages#11727)
<#11727 (comment)>
- I followed [the version and CHANGELOG instructions], using [semantic
versioning] and the [repository CHANGELOG style], or I have commented below
to indicate which documented exception this PR falls under[^1].
I don't see any changes addressing this item.
—
Reply to this email directly, view it on GitHub
<#11727 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALUEMUBTOREB4B4W2TH6DC343R4UVAVCNFSM6AAAAACZCKLOV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DIOBZGM2DCNRQGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
There was a problem hiding this comment.
Code Review
This pull request clarifies that the mimeType property in the cross_file package is not inferred from the file path or contents. Documentation updates reflecting this behavior were made in the CHANGELOG.md, README.md, and the XFile class across its base, HTML, and IO implementations. I have no feedback to provide.
It appears that your change was to delete the checklist item. Could you explain why you believe that our required contribution steps do not apply to this PR? |
ea8232e to
df9109d
Compare
|
You’re right, I misunderstood that checklist item earlier.
I’ve updated the PR to follow the version and CHANGELOG process now:
- bumped the package version in `pubspec.yaml.`
- updated the package `CHANGELOG.md` with the release heading and entry
- restored the checklist item in the PR description
…On Tue, May 19, 2026, 7:30 PM stuartmorgan-g ***@***.***> wrote:
*stuartmorgan-g* left a comment (flutter/packages#11727)
<#11727 (comment)>
I will update the PR checks.
It appears that your change was to delete the checklist item. Could you
explain why you believe that our required contribution steps do not apply
to this PR?
—
Reply to this email directly, view it on GitHub
<#11727 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ALUEMUFWBYFFTVQQCDKHS5T43SR3DAVCNFSM6AAAAACZCKLOV2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHM2DIOJQHAZDKOBVGE>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Clarifies the
cross_filedocumentation forXFile.mimeType.This PR documents that
mimeTypeis not inferred from the file path or file contents. It is only available when provided while creating theXFile, or when available from the platform-backed file.Fixes flutter/flutter#93379
Test exemption: This is a documentation-only change that clarifies existing API behavior, so no new tests were added.
Validation run:
dart analyzedart testdart test test/readme_excerpts_test.dartPre-Review Checklist
[shared_preferences]///).